package com.hzqy.service.produceInfoJs;

import com.hzqy.commons.utils.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

@Service
public class CountyEducationStyleExpandServiceBean {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());

	public Object updateInfoJs(String url, String path,String serverIdStr){
		LOG.debug("url="+url);
		LOG.debug("path="+path);
		LOG.debug("serverIdStr="+serverIdStr);
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("code","-1");
		if(url==null||"".equals(url)){
			map.put("message","访问路径不正确");
			return map;
		}
		if(path==null||"".equals(path)){
			map.put("message","物理路径不正确");
			return map;
		}
		if(serverIdStr==null||"".equals(serverIdStr)){
			map.put("message","serverIdStr不正确");
			return map;
		}
		String sendUrl="";
		Map<String,String> ret =new HashMap<String, String>();
		try{
			url="http://"+url+"/web/school_hd/produceInfoJs/countyEducationStyle.do";
			String epg_info="<server_ip>220.191.139.79</server_ip><group_name>10013</group_name><group_path></group_path><oss_user_id>1570qzkhjyj</oss_user_id><page_url>http://220.191.139.79:8080/EPG/jsp/ZJTELECOMHotelHD/en/vis_to_page.jsp</page_url><partner>HWGDHotelHD</partner>";
			sendUrl=url+"?path="+ URLEncoder.encode(path, "utf-8")+"&serveridStr="+URLEncoder.encode(serverIdStr, "utf-8")
					+"&epg_info="+ URLEncoder.encode(epg_info, "utf-8");
			ret= HttpUtil.get(sendUrl,20*60*1000,10*1000);
			map.put("code","0");
			map.put("ret",ret);
		}catch (Exception e){
			LOG.error("url请求失败:"+sendUrl,e);
			map.put("Exception","url请求失败:"+sendUrl+"e");
		}
		return map;
	}
	public static void main(String[] args) {
		String path=System.getProperty("user.dir")+"/school_hd/county_education_style_expand_js/";
		System.out.println(path);
	}
}
